home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / Goodies / Animation Libraries / GENetRelease2ƒ / GETest / GELogo.c next >
Text File  |  1994-06-10  |  2KB  |  90 lines

  1. /*
  2.     GELogo.c
  3.     
  4.     Graphic Elements © 1994 floating sign
  5.     
  6.     Copyright 1994 by Al Evans. All rights reserved.
  7.     
  8.     5/31/94
  9.     
  10. */
  11.  
  12. #include "GELogo.h"
  13. #include "SFXCtrlr.h"
  14. #include "SFXProcs.h"
  15.  
  16. typedef struct {
  17.             Boolean signOn;
  18.             RGBColor color[2];
  19. } BlinkRec, *BlinkRecPtr;
  20.  
  21. BlinkRec    logoBlink;
  22. Str255            logoText = "\pGraphic Elements";
  23. Str255            line2 = "\p©1994 by Al Evans";
  24.  
  25. Boolean LoadLogoScene(GEWorldPtr world)
  26. {
  27.     GrafElPtr        logoElement;
  28.     GrafElPtr        secondLine;
  29.     short            fontNum;
  30.     
  31.     GrafElPtr        ctrlr;
  32.     
  33.     GetFNum("\pPalatino", &fontNum);
  34.     
  35.     logoBlink.signOn = false;
  36.     logoBlink.color[0].red = 194 << 8;
  37.     logoBlink.color[0].green = 194 << 8;
  38.     logoBlink.color[0].blue = 0;
  39.     logoBlink.color[1].red = 240 << 8;
  40.     logoBlink.color[1].green = 240 << 8;
  41.     logoBlink.color[1].blue = 46 << 8;
  42.     
  43.     //Create sign
  44.     logoElement = NewTextGraphic(world, logoID, logoPlane, 0, 0, srcOr,
  45.                             fontNum, bold, 24, logoBlink.color[0], logoText);
  46.     if (!logoElement) return false;
  47.     
  48.     secondLine = NewTextGraphic(world, logoID+1, logoPlane + 1, 0, 0, srcOr,
  49.                             fontNum, 0, 14, logoBlink.color[0], line2);
  50.     if (!secondLine) return false;
  51.  
  52.     //Position two lines -- 
  53.     //first line horizontally centered a little above middle of world, 
  54.     //second line centered beneath first line    
  55.     PtrMoveElementTo(world, logoElement, 
  56.         (RectWidth(&world->animationRect) - RectWidth(&logoElement->animationRect)) / 2,
  57.         (RectHeight(&world->animationRect) - RectHeight(&logoElement->animationRect)) / 2 -
  58.         ScaleToWorld(world, 36), false);
  59.     PtrMoveElementTo(world, secondLine, logoElement->animationRect.left +
  60.         ((RectWidth(&logoElement->animationRect) - RectWidth(&secondLine->animationRect)) / 2),
  61.         logoElement->animationRect.bottom, false);
  62.             
  63.     //Set up blinking action
  64.     SetCollision(world, logoID, DoLogoHit, 400);
  65.     
  66.     //Try for special effect...
  67.     ctrlr = DoGESFX(world, 'SFX ', logoElement, SFXVWipe, 20, 2000, 60, true, false);
  68.     ctrlr = DoGESFX(world, 'SFX1', secondLine, SFXHWipe, 20, 5000, 60, true, false);
  69.     return true;
  70.                     
  71. }
  72.  
  73. pascal void DoLogoHit(GEWorldPtr world, GrafElPtr logo, GEDirection dir, 
  74.                                     CollisionPhase phase, GrafElPtr objHit)
  75. {
  76.     switch (phase) {
  77.         case collisionBegin:
  78.             ((TextGraphicPtr) logo)->tgColor = logoBlink.color[true];
  79.             ChangedRect(world, &logo->animationRect);
  80.             break;
  81.         case collisionContinue:
  82.             break;
  83.         case collisionEnd:
  84.             ((TextGraphicPtr) logo)->tgColor = logoBlink.color[false];
  85.             ChangedRect(world, &logo->animationRect);
  86.             break;
  87.     }
  88. }
  89.  
  90.